{extend name="common:base" /}

{block name="main"}
<!--body wrapper start-->
<div class="wrapper">
    <div class="row">
        <div class="col-md-12">
            <!--breadcrumbs start -->
            <ul class="breadcrumb panel">
                <li><a href="{:url('Index/index')}"><i class="fa fa-home"></i> 控制台</a></li>
                <li><a href="{:url('Users/index')}">机器人管理</a></li>
                <li class="active">编辑机器人</li>
            </ul>
            <!--breadcrumbs end -->
        </div>
    </div>
    <div class="row">
        <div class="col-lg-12">
            <section class="panel">
                <header class="panel-heading">
                    编辑机器人
                </header>
                <div class="panel-body">
                    <div class="form">
                       <form class="form-horizontal adminex-form userForm" action="{:url('member/robot_edit')}" method="post">

                                    <div class="form-group">
                                        <label  class="control-label col-lg-2">机器人昵称</label>
                                        <div class="col-lg-4">
                                            <input type="text" name="nickname"  class="form-control" value="{$data.nickname}">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label  class="control-label col-lg-2">机器人头像</label>
                                        <div class="col-lg-8">
                                            <img height="100px"  src="URL_IMG{$data.logo}"/><br />
                                            <p style="color:green"> 图片不要传太大，不然会影响加载速度哦</p>
                                          <span class="file_p text-center" id="btn_logo">
                                                   <label >点此选择图片</label>
                                                   <img height="100px"   id="btn_logo_img" src="__IMG__/add-button.jpg"/><br />
                                                   <input type="hidden" name="logo" value="{$data.logo}"/>
                                          </span>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label  class="control-label col-lg-2">彩种</label>
                                        <div class="col-lg-4">
                                            <select name="cate" class="form-control ">
                                                <option value="" >选择彩种</option>
                                                {foreach $cates as $v}
                                                <option value="{$v.id}"  {if (isset($data.cate) && $data.cate eq $v.id )}selected="selected"{/if}>{$v.name}</option>
                                                {/foreach}
                                            </select>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label  class="control-label col-lg-2">房间</label>
                                        <div class="col-lg-4">
                                            <select name="hall" class="form-control ">
                                                <option value="" >选择房间</option>
                                                <option value="1" {if (isset($data.hall) && $data.hall eq 1 )}selected {/if}>1号房间</option>
                                                <option value="2" {if (isset($data.hall) && $data.hall eq 2 )}selected {/if}>2号房间</option>
                                                <option value="3" {if (isset($data.hall) && $data.hall eq 3 )}selected {/if}>3号房间</option>
                                                <option value="4" {if (isset($data.hall) && $data.hall eq 4 )}selected {/if}>4号房间</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label  class="control-label col-lg-2">最低投注</label>
                                        <div class="col-lg-4">
                                            <input type="text" name="down"  class="form-control" value="{$data.down}">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label  class="control-label col-lg-2">最高投注</label>
                                        <div class="col-lg-4">
                                            <input type="text" name="up" class="form-control" value="{$data.up}">
                                        </div>
                                    </div>
                                   <div class="form-group">
                                       <label  class="control-label col-lg-2">间隔时间（秒）</label>
                                       <div class="col-lg-4">
                                           <input type="text" name="min_time" class="form-control" value="{$data.min_time}">
                                       </div>
                                   </div>
                                   <div class="form-group">
                                       <label  class="control-label col-lg-2">开启/关闭</label>
                                       <div class="col-lg-4">
                                           <input type="radio" name="status"  value="1"  {if $data.status==1} checked {/if}>开启
                                           <input type="radio" name="status"  value="0" {if $data.status==0} checked {/if}>关闭
                                       </div>
                                   </div>

                                <div class="form-group">
                                    <input type="hidden" name="id" value="{$data.id}">
                                    <button class="btn btn-primary " type="submit">保存</button>
                                </div>
                            </form>
                    </div>
                </div>
            </section>
        </div>
    </div>
</div>
<!--body wrapper end-->
<script src="__JS__/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="__JS__/Plupload/plupload.full.min.js"></script>
<script type="text/javascript">

    var ids = new Array("btn_logo");

    $.each(ids,function(i,n){

        var self = this.toString();

        var uploader_avatar = new plupload.Uploader({

            runtimes: 'gears,html5,html4,silverlight,flash', //上传插件初始化选用那种方式的优先级顺序

            browse_button: self, // 上传按钮

            url: "{:url('upload_one')}", //远程上传地址

            flash_swf_url: '__DTSC__/Moxie.swf',//flash文件地址

            silverlight_xap_url: '__DTSC__/Moxie.xap', //silverlight文件地址

            filters: {

                max_file_size: '100mb', //最大上传文件大小（格式100b, 10kb, 10mb, 1gb）

                mime_types: [//允许文件上传类型

                    {title: "files", extensions: "jpg,png,gif,jpeg"}

                ]

            },

            multi_selection: false, //true:ctrl多文件上传, false 单文件上传

            init: {

                FilesAdded: function(up, files) { //文件上传前

                    uploader_avatar.start();

                },

                UploadProgress: function(up, file) { //上传中，显示进度条

                    var percent = file.percent;

                    $("#" + file.id).find('.bar').css({"width": percent + "%"});

                    $("#" + file.id).find(".percent").text(percent + "%");

                },

                FileUploaded: function(up, file, info) { //文件上传成功的时候触发

                    var data = eval("(" + info.response + ")");//解析返回的json数据

                    if(data.status == 1){

                        var img = self+'_img'

                        document.getElementById(img).src = data.pic;

                        document.getElementById(img).width = 200;

                        $('#'+self).find('i').remove();

                        $('#'+self).find('input').val(data.picd);

                    }else{

                        alert(data.error);

                    }

                },

                Error: function(up, err) { //上传出错的时候触发

                    alert(err.message);

                }

            }

        });

        uploader_avatar.init();

    })







</script>
{/block}


